package org.dxy.domain.model.aggregate;

import org.dxy.domain.event.mbom.*;
import org.dxy.domain.event.substitute.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * MBOM聚合根接口
 * @author dxy
 * @createTime 2025/9/10
 */
public interface MBOMAggRoot extends AggregateRoot {
    
    /**
     * 从EBOM同步创建MBOM
     */
    MBOMSyncedFromEBOMEvent syncFromEBOM(Long ebomId, String ebomVersion, Long productId);
    
    /**
     * 创建MBOM
     */
    MBOMCreatedEvent create(String mbomCode, String mbomName, Long productId, String version);
    
    /**
     * 更新MBOM信息
     */
    void update(String mbomName, String description);
    
    /**
     * 提交审核
     */
    MBOMSubmittedForReviewEvent submitForReview(Long reviewerId, String submitComment);
    
    /**
     * 审核通过
     */
    MBOMApprovedEvent approve(String approveComment);
    
    /**
     * 审核拒绝
     */
    MBOMRejectedEvent reject(String rejectReason);
    
    /**
     * 发布MBOM
     */
    MBOMReleasedEvent release();
    
    /**
     * 分配给工单
     */
    MBOMAssignedToWorkOrderEvent assignToWorkOrder(Long workOrderId);
    
    /**
     * 作废MBOM
     */
    MBOMObsoletedEvent obsolete(String obsoleteReason);
    
    /**
     * 获取MBOM ID
     */
    Long getId();
    
    /**
     * 获取当前状态
     */
    String getStatus();
    
    /**
     * 获取版本号
     */
    String getVersion();
    
    /**
     * 获取产品ID
     */
    Long getProductId();
    
    // ========== 替代料相关方法 ==========
    
    /**
     * 添加替代料
     */
    SubstituteMaterialAddedEvent addSubstituteMaterial(
            Long mbomItemId, 
            Long substituteMaterialId, 
            BigDecimal substituteRatio, 
            Integer priority,
            LocalDateTime validFrom,
            LocalDateTime validTo);
    
    /**
     * 更新替代料
     */
    SubstituteMaterialUpdatedEvent updateSubstituteMaterial(
            Long substituteId,
            BigDecimal substituteRatio,
            Integer priority,
            LocalDateTime validFrom,
            LocalDateTime validTo);
    
    /**
     * 移除替代料
     */
    SubstituteMaterialRemovedEvent removeSubstituteMaterial(Long substituteId);
    
    /**
     * 审核通过替代料
     */
    SubstituteMaterialApprovedEvent approveSubstituteMaterial(Long substituteId);
    
    /**
     * 审核拒绝替代料
     */
    SubstituteMaterialRejectedEvent rejectSubstituteMaterial(Long substituteId, String rejectReason);
    
    /**
     * 工单应用替代料
     */
    SubstituteMaterialAppliedToWorkOrderEvent applySubstituteMaterialToWorkOrder(
            Long substituteId, 
            Long workOrderId, 
            BigDecimal actualQuantity);
}